//
//  GameInfoCell.swift
//  appstore
//
//  Created by llbt-sk on 2019/11/7.
//  Copyright © 2019 Roy. All rights reserved.
//

import UIKit

class GameInfoCell: UITableViewCell {
    
    var headImageView:UIImageView!
    var titleLabel:UILabel!
    var detailTitleLabel:UILabel!
    var downLoadImage:UIImageView!
    var commitImage:UIImageView!
    var dataLabel:UILabel!
    var rateLabel:UILabel!
    var typeLabel:UILabel!
    var ageDataLabel:UILabel!
    var ageLabel:UILabel!
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        self.initView()
    }
    
    func initView() -> Void {
        // headImageView
        headImageView = UIImageView()
        headImageView.image = UIImage(named: "logo_game")
        self.contentView.addSubview(headImageView)
        headImageView.snp.makeConstraints { (make) in
            make.top.left.equalTo(20.0)
            make.width.height.equalTo(120.0)
        }
        
        // titleLabel
        titleLabel = UILabel()
        titleLabel.text = "Onmyoji"
        titleLabel.font = UIFont.systemFont(ofSize: 22.0)
        self.contentView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { (make) in
            make.left.equalTo(headImageView.snp.right).offset(20.0)
            make.top.equalTo(headImageView.snp.top).offset(10.0)
            make.width.equalTo(100.0)
            make.height.equalTo(25.0)
        }
        
        // detailTitleLabel
        detailTitleLabel = UILabel()
        detailTitleLabel.font = UIFont.systemFont(ofSize: 15.0)
        detailTitleLabel.textColor = UIColor.gray
        detailTitleLabel.text = "The best game"
        self.contentView.addSubview(detailTitleLabel)
        detailTitleLabel.snp.makeConstraints { (make) in
            make.left.equalTo(titleLabel)
            make.top.equalTo(titleLabel.snp.bottom).offset(5.0)
            make.width.equalTo(150.0)
            make.height.equalTo(20.0)
        }
        
        // downLoadImage
        downLoadImage = UIImageView()
        downLoadImage.image = UIImage(named: "detail_download")
        self.contentView.addSubview(downLoadImage)
        downLoadImage.snp.makeConstraints { (make) in
            make.left.equalTo(titleLabel)
            make.bottom.equalTo(headImageView.snp.bottom)
            make.width.height.equalTo(30.0)
        }
        
        // commitImage
        commitImage = UIImageView()
        commitImage.image = UIImage(named: "detail_more")
        self.contentView.addSubview(commitImage)
        commitImage.snp.makeConstraints { (make) in
            make.right.equalTo(-20.0)
            make.top.equalTo(downLoadImage)
            make.width.height.equalTo(30.0)
        }
        
        // dataLabel
        dataLabel = UILabel()
        dataLabel.text = "4.0, 250rateings"
        dataLabel.textColor = UIColor.gray
        dataLabel.font = UIFont.systemFont(ofSize: 12.0)
        self.contentView.addSubview(dataLabel)
        dataLabel.snp.makeConstraints { (make) in
            make.left.equalTo(20.0)
            make.bottom.equalTo(-20.0)
            make.width.equalTo(120.0)
            make.height.equalTo(14.0)
        }
        
        // ageLabel
        ageLabel = UILabel()
        ageLabel.text = "Age"
        ageLabel.textColor = .gray
        ageLabel.font = UIFont.systemFont(ofSize: 12.0)
        self.contentView.addSubview(ageLabel)
        ageLabel.snp.makeConstraints { (make) in
            make.right.equalTo(-20.0)
            make.bottom.equalTo(-20.0)
            make.width.equalTo(30.0)
            make.height.equalTo(14.0)
        }
        
        // ageDataLabel
        ageDataLabel = UILabel()
        ageDataLabel.textColor = .gray
        ageDataLabel.text = "9+"
        ageDataLabel.font = UIFont.systemFont(ofSize: 22.0)
        self.contentView.addSubview(ageDataLabel)
        ageDataLabel.snp.makeConstraints { (make) in
            make.centerX.equalTo(ageLabel)
            make.bottom.equalTo(ageLabel.snp.top).offset(-10.0)
            make.width.equalTo(30.0)
            make.height.equalTo(22.0)
        }
        
        // typeLabel
        typeLabel = UILabel()
        typeLabel.text = "strategy"
        typeLabel.textColor = UIColor.gray
        typeLabel.font = UIFont.systemFont(ofSize: 12.0)
        self.contentView.addSubview(typeLabel)
        typeLabel.snp.makeConstraints { (make) in
            make.right.equalTo(ageLabel.snp.left).offset(-45.0)
            make.bottom.equalTo(-20.0)
            make.width.equalTo(50.0)
            make.height.equalTo(14.0)
        }
        
        // rateLabel
        rateLabel = UILabel()
        rateLabel.text = "#31"
        rateLabel.textColor = .gray
        rateLabel.font = UIFont.systemFont(ofSize: 22.0)
        self.contentView.addSubview(rateLabel)
        rateLabel.snp.makeConstraints { (make) in
            make.centerX.equalTo(typeLabel)
            make.bottom.equalTo(typeLabel.snp.top).offset(-10.0)
            make.width.equalTo(40.0)
            make.height.equalTo(22.0)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
